extends ItemList


# Declare member variables here. Examples:
# var a = 2
# var b = "text"

onready var GRID = find_parent("GRID")

# Called when the node enters the scene tree for the first time.
func _ready():
	add_item("nothing")
	for i in CellType.SIGNAL_COUNT:
		add_item("signal " + str(i))

	connect("item_activated",self,"on_layer_selected")

func on_layer_selected(index):
	highlight_layer(index)

func highlight_layer(index):

	if index == 0 :
		#unhighlighting everything
		for i in GRID.visual_cells:
			for c in i:
				if c:
					c.modulate.a = 1
		return


	var signal_num = index - 1
	for i in GRID.visual_cells:
		for c in i:
			if c and c.cell:
				c.modulate.a = (c.cell.field_vector[signal_num] + 1)/2
	pass

func highlight_selected():
	highlight_layer(get_selected_items()[0] if get_selected_items() else 0)
